package com.columboid.protocol.syncml.devicemgmt;

/**
 * Schema fragment(s) for this class:
 * 
 * <pre>
 * &lt;xs:element xmlns:ns=&quot;http://protocol.columboid.com/syncml/devicemgmt&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; name=&quot;Occurrence&quot;&gt;
 *   &lt;xs:complexType&gt;
 *     &lt;xs:choice&gt;
 *       &lt;xs:element ref=&quot;ns:One&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:ZeroOrOne&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:ZeroOrMore&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:OneOrMore&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:ZeroOrN&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:OneOrN&quot;/&gt;
 *     &lt;/xs:choice&gt;
 *   &lt;/xs:complexType&gt;
 * &lt;/xs:element&gt;
 * </pre>
 */
public class Occurrence {
	private int occurrenceSelect = -1;
	private static final int ONE_CHOICE = 0;
	private static final int ZERO_OR_ONE_CHOICE = 1;
	private static final int ZERO_OR_MORE_CHOICE = 2;
	private static final int ONE_OR_MORE_CHOICE = 3;
	private static final int ZERO_OR_N_CHOICE = 4;
	private static final int ONE_OR_N_CHOICE = 5;
	private One one;
	private ZeroOrOne zeroOrOne;
	private ZeroOrMore zeroOrMore;
	private OneOrMore oneOrMore;
	private ZeroOrN zeroOrN;
	private OneOrN oneOrN;

	private void setOccurrenceSelect(int choice) {
		if (occurrenceSelect == -1) {
			occurrenceSelect = choice;
		} else if (occurrenceSelect != choice) {
			throw new IllegalStateException(
					"Need to call clearOccurrenceSelect() before changing existing choice");
		}
	}

	/**
	 * Clear the choice selection.
	 */
	public void clearOccurrenceSelect() {
		occurrenceSelect = -1;
	}

	/**
	 * Check if One is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifOne() {
		return occurrenceSelect == ONE_CHOICE;
	}

	/**
	 * Get the 'One' element value.
	 * 
	 * @return value
	 */
	public One getOne() {
		return one;
	}

	/**
	 * Set the 'One' element value.
	 * 
	 * @param one
	 */
	public void setOne(One one) {
		setOccurrenceSelect(ONE_CHOICE);
		this.one = one;
	}

	/**
	 * Check if ZeroOrOne is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifZeroOrOne() {
		return occurrenceSelect == ZERO_OR_ONE_CHOICE;
	}

	/**
	 * Get the 'ZeroOrOne' element value.
	 * 
	 * @return value
	 */
	public ZeroOrOne getZeroOrOne() {
		return zeroOrOne;
	}

	/**
	 * Set the 'ZeroOrOne' element value.
	 * 
	 * @param zeroOrOne
	 */
	public void setZeroOrOne(ZeroOrOne zeroOrOne) {
		setOccurrenceSelect(ZERO_OR_ONE_CHOICE);
		this.zeroOrOne = zeroOrOne;
	}

	/**
	 * Check if ZeroOrMore is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifZeroOrMore() {
		return occurrenceSelect == ZERO_OR_MORE_CHOICE;
	}

	/**
	 * Get the 'ZeroOrMore' element value.
	 * 
	 * @return value
	 */
	public ZeroOrMore getZeroOrMore() {
		return zeroOrMore;
	}

	/**
	 * Set the 'ZeroOrMore' element value.
	 * 
	 * @param zeroOrMore
	 */
	public void setZeroOrMore(ZeroOrMore zeroOrMore) {
		setOccurrenceSelect(ZERO_OR_MORE_CHOICE);
		this.zeroOrMore = zeroOrMore;
	}

	/**
	 * Check if OneOrMore is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifOneOrMore() {
		return occurrenceSelect == ONE_OR_MORE_CHOICE;
	}

	/**
	 * Get the 'OneOrMore' element value.
	 * 
	 * @return value
	 */
	public OneOrMore getOneOrMore() {
		return oneOrMore;
	}

	/**
	 * Set the 'OneOrMore' element value.
	 * 
	 * @param oneOrMore
	 */
	public void setOneOrMore(OneOrMore oneOrMore) {
		setOccurrenceSelect(ONE_OR_MORE_CHOICE);
		this.oneOrMore = oneOrMore;
	}

	/**
	 * Check if ZeroOrN is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifZeroOrN() {
		return occurrenceSelect == ZERO_OR_N_CHOICE;
	}

	/**
	 * Get the 'ZeroOrN' element value.
	 * 
	 * @return value
	 */
	public ZeroOrN getZeroOrN() {
		return zeroOrN;
	}

	/**
	 * Set the 'ZeroOrN' element value.
	 * 
	 * @param zeroOrN
	 */
	public void setZeroOrN(ZeroOrN zeroOrN) {
		setOccurrenceSelect(ZERO_OR_N_CHOICE);
		this.zeroOrN = zeroOrN;
	}

	/**
	 * Check if OneOrN is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifOneOrN() {
		return occurrenceSelect == ONE_OR_N_CHOICE;
	}

	/**
	 * Get the 'OneOrN' element value.
	 * 
	 * @return value
	 */
	public OneOrN getOneOrN() {
		return oneOrN;
	}

	/**
	 * Set the 'OneOrN' element value.
	 * 
	 * @param oneOrN
	 */
	public void setOneOrN(OneOrN oneOrN) {
		setOccurrenceSelect(ONE_OR_N_CHOICE);
		this.oneOrN = oneOrN;
	}
}
